package com.sky.controller.admin;

import com.sky.dto.*;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderPaymentVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderSubmitVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Slf4j
@Api(tags = "用户订单相关接口")
public class OrderController {
@Autowired
private OrderService orderService;

    @GetMapping("/details/{id}")
    @ApiOperation("查询订单")
    public Result select(@PathVariable Long id){
        return Result.success( orderService.selectById(id));
    }

    @GetMapping("/conditionSearch")
    @ApiOperation("订单搜索")
    public Result<PageResult> findOrder(OrdersPageQueryDTO ordersPageQueryDTO){
        return Result.success(orderService.AdminPageQuery(ordersPageQueryDTO));
    }


    @GetMapping("/statistics")
    @ApiOperation("统计数字")
    public Result<OrderStatisticsVO> statistics(){
        return Result.success(orderService.statistics());
    }

    @PutMapping("/confirm")
    @ApiOperation("接单")
    public Result receiveOrder(@RequestBody OrdersConfirmDTO ordersConfirmDTO){
        orderService.receive(ordersConfirmDTO);
        return Result.success();
    }

    @PutMapping("/delivery/{id}")
    @ApiOperation("派送")
    public Result send(@PathVariable Long id){
        orderService.send(id);
        return Result.success();
    }


    @PutMapping("/complete/{id}")
    @ApiOperation("完成")
    public Result complete(@PathVariable Long id){
        orderService.complete(id);
        return Result.success();
    }
    @PutMapping("/cancel")
    @ApiOperation("取消订单")
    public Result cancelOrder(@RequestBody OrdersCancelDTO ordersCancelDTO){
        orderService.adminCancel(ordersCancelDTO);
        return Result.success();
    }

    @PutMapping("/rejection")
    @ApiOperation("拒绝订单")
    public Result reject(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
        orderService.reject(ordersRejectionDTO);
        return Result.success();
    }
}
